package zjitc.net.utils.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.BasicDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.attribute.BasicFileAttributes;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class DBCutils {
    public static DataSource ds=null;
    static {

        Properties properties=new Properties();
        InputStream in =DBCutils.class.getClassLoader().getResourceAsStream("DBCP-config.properties");
        try {
            properties.load(in);
            ds=BasicDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
    public static Connection getConnection()throws SQLException {
        return  ds.getConnection();
    }

}
